package com.topnav.mc.admin.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.admin.entity.DeviceLog;
import com.topnav.mc.admin.entity.bean.DeviceLogBean;
import com.topnav.mc.admin.entity.param.DeviceLogParam;
import com.topnav.mc.base.mc.McMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
public interface DeviceLogMapper extends McMapper<DeviceLog, DeviceLogBean, DeviceLogParam> {
    String commSql = " SELECT l.*," +
            " d.name AS deviceName, o.name AS orgName, o.short_name AS shortName, o.path," +
            " u.code AS userCode, u.name AS userName" +
            " FROM mc_device_log l " +
            " LEFT JOIN mc_device d ON l.device_id = d.id " +
            " LEFT JOIN mc_organization o ON d.org_id = o.id " +
            " LEFT JOIN mc_user u ON d.user_id = u.id " +
            " ${ew.customSqlSegment}";

    @Select(commSql)
    DeviceLogBean selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    List<DeviceLogBean> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    Page<DeviceLogBean> selectInfoPage(Page<DeviceLogParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);
}
